﻿using System;

namespace SharePoint.Contrib.Extensions
{
    /// <summary>
    /// Extensions for the String class
    /// </summary>
    public static class StringExtensions
    {
        /// <summary>
        /// Returns the string as an exception
        /// </summary>
        /// <param name="args">optional args for string.format</param>
        public static Exception AsException(this string instance, params object[] args)
        {
            return new Exception(string.Format(instance, args));
        }

        /// <summary>
        /// Returns the string as an exception
        /// </summary>
        /// <param name="args">optional args for string.format</param>
        /// <param name="inner">an inner exception to append</param>
        public static Exception AsException(this string instance, Exception inner, params object[] args)
        {
            return new Exception(string.Format(instance, args), inner);
        }
 
    }
}
